<?php

namespace App\Libs\Tools;


use DateTime;
use Illuminate\Support\Facades\Config;
use Ramsey\Uuid\Uuid;

class UploadTools{
    public static function generateUploadFileRelativePath($upload_file,$pre_path=null){
        $relativePath='';
        if($pre_path!=null){
            $relativePath=$relativePath.$pre_path.'/';
        }
        $relativePath=(new DateTime())->format('Y/m/d/').$relativePath.Uuid::uuid4().'.'.$upload_file->guessClientExtension();
        return $relativePath;
    }

    public static function getFileUrl($relativePath){
        return Config::get('filesystems.disks.local.url').$relativePath;
    }
    public static function getFilePath($relativePath){
        return Config::get('filesystems.disks.local.root').$relativePath;
    }

}